# -*- coding:utf-8 -*-
import json
from selenium import webdriver



LOGIN_URL = 'https://www.tianyancha.com/'


def save_cookies():

    browser = webdriver.Chrome( )

    browser.get(LOGIN_URL)
    a = input("请在登录成功3秒后按下回车键获取cookies:")

    try:

        jsonCookies = browser.get_cookies()
        with open('cookies.txt', 'w') as f:
            f.write(json.dumps(jsonCookies))
        print(jsonCookies)
        # browser.close()

    except Exception as e:
        print(e)

if __name__ == '__main__':
    save_cookies()
